/**
 * 人事评估意见
 */
import React from 'react';
import { Form, Tag } from 'antd';
import { FormLayout } from '../../components';
import Previewer from '../Previewer';

const TAG_MAP = {
    0: (
        <Tag color="red" style={{ background: 'none', border: 'none' }}>
            不合格
        </Tag>
    ),
    1: (
        <Tag color="green" style={{ background: 'none', border: 'none' }}>
            合格
        </Tag>
    ),
    2: (
        <Tag color="red" style={{ background: 'none', border: 'none' }}>
            需观察
        </Tag>
    )
};

export default function AssessHRDetail({ data = {} }) {
    const { evaluationType, opinion, announcements, file = [] } = data;
    const newEmployeeFlag = React.useMemo(() => {
        const currentUser = JSON.parse(localStorage.getItem('user') || null) ?? {};
        return currentUser?.employeeCode === data?.employeeCode;
    }, [data?.employeeCode]);
    return (
        <div>
            <FormLayout type="full">
                <Form.Item label="人事评价">{TAG_MAP[evaluationType]}</Form.Item>
            </FormLayout>
            {!newEmployeeFlag && (
                <FormLayout type="full">
                    <Form.Item label="评价说明">{opinion}</Form.Item>
                </FormLayout>
            )}
            <FormLayout type="full">
                <Form.Item label="注意事项">{announcements}</Form.Item>
            </FormLayout>
            <FormLayout type="full">
                <Form.Item label="附件">{file[0] && <Previewer data={file[0]} />}</Form.Item>
            </FormLayout>
        </div>
    );
}
